import {reqGoodsInfo} from '@/api'
import { Message } from 'element-ui'
const actions ={
    //获取商品信息
    async getGoodsInfo({commit},searchParams){
        const result =await reqGoodsInfo(searchParams)
        if(result.code ===200){
            commit('SAVE_GOODSINFO',result.data)
            // console.log(result.data);
        }else{
            Message.error(result.message)
        }
    },
    
    
}
const mutations={
    SAVE_GOODSINFO(state,info){
        state.goodsInfo = info
    },
   
}

const state = {
    goodsInfo:{
        attrsList:[],
        goodsList:[{}],
        trademarkList:[{}],
        pageNo:'',
        pageSize:'',
        total:'',
        totalPages:''
    }
}

const getters = {
    attrsList(state){
        return state.goodsInfo.attrsList
    },
    trademarkList(state){
        return state.goodsInfo.trademarkList
    },
    goodsList(state){
        return state.goodsInfo.goodsList
    },
    total(state){
        return state.goodsInfo.total
    }
}

export default {
    namespaced:true,
    actions,
    mutations,
    state,
    getters,
}